# 数据单位
KB = 1024
MB = 1024 * KB
GB = 1024 * MB
TB = 1024 * GB

# http响应状态码信息
HTTP_STATUS_CODES = {
    # 1xx: 信息响应
    100: ("Continue", "服务器已收到请求头，客户端应继续发送请求体"),
    101: ("Switching Protocols", "请求者要求切换协议(如WebSocket)"),
    102: ("Processing", "服务器正在处理请求(用于长时间请求)"),
    103: ("Early Hints", "预加载提示(与Link头配合使用)"),
    
    # 2xx: 成功响应
    200: ("OK", "请求成功"),
    201: ("Created", "资源创建成功"),
    202: ("Accepted", "请求已接受但尚未处理完成"),
    203: ("Non-Authoritative Information", "非权威信息(代理修改了原始响应)"),
    204: ("No Content", "请求成功，但无返回内容"),
    205: ("Reset Content", "要求客户端重置文档视图"),
    206: ("Partial Content", "部分内容响应(用于分块下载/断点续传)"),
    207: ("Multi-Status", "多状态响应(WebDAV扩展)"),
    208: ("Already Reported", "资源已报告(WebDAV扩展)"),
    226: ("IM Used", "服务器已完成请求，返回实体首部包含的信息"),
    
    # 3xx: 重定向
    300: ("Multiple Choices", "多选项(资源有多种表现方式)"),
    301: ("Moved Permanently", "永久重定向"),
    302: ("Found", "临时重定向"),
    303: ("See Other", "查看其他位置"),
    304: ("Not Modified", "资源未修改(可使用缓存)"),
    305: ("Use Proxy", "需使用代理访问"),
    307: ("Temporary Redirect", "临时重定向(保持请求方法不变)"),
    308: ("Permanent Redirect", "永久重定向(保持请求方法不变)"),
    
    # 4xx: 客户端错误
    400: ("Bad Request", "请求语法错误"),
    401: ("Unauthorized", "未认证(需提供身份凭证)"),
    402: ("Payment Required", "需付费访问(保留状态码)"),
    403: ("Forbidden", "服务器拒绝请求(无权限访问)"),
    404: ("Not Found", "资源不存在"),
    405: ("Method Not Allowed", "请求方法被禁用"),
    406: ("Not Acceptable", "无法提供符合Accept头的资源"),
    407: ("Proxy Authentication Required", "代理需要认证"),
    408: ("Request Timeout", "请求超时"),
    409: ("Conflict", "资源冲突(如多个编辑冲突)"),
    410: ("Gone", "资源已被永久删除"),
    411: ("Length Required", "需要Content-Length头"),
    412: ("Precondition Failed", "预处理条件失败"),
    413: ("Payload Too Large", "请求体过大"),
    414: ("URI Too Long", "请求URI过长"),
    415: ("Unsupported Media Type", "媒体类型不受支持"),
    416: ("Range Not Satisfiable", "请求范围无法满足"),
    417: ("Expectation Failed", "Expect请求头无法满足"),
    418: ("I'm a teapot", "彩蛋状态码(超文本咖啡壶控制协议)"),
    421: ("Misdirected Request", "请求被发送到错误服务器"),
    422: ("Unprocessable Entity", "无法处理的实体(WebDAV)"),
    423: ("Locked", "资源被锁定(WebDAV)"),
    424: ("Failed Dependency", "依赖请求失败(WebDAV)"),
    425: ("Too Early", "请求发送过早(可能重放攻击)"),
    426: ("Upgrade Required", "需升级协议"),
    428: ("Precondition Required", "需要条件请求"),
    429: ("Too Many Requests", "请求过于频繁(限流)"),
    431: ("Request Header Fields Too Large", "请求头字段过大"),
    451: ("Unavailable For Legal Reasons", "因法律原因不可访问"),
    
    # 5xx: 服务端错误
    500: ("Internal Server Error", "服务器内部错误"),
    501: ("Not Implemented", "功能未实现"),
    502: ("Bad Gateway", "网关错误(上游服务器无效响应)"),
    503: ("Service Unavailable", "服务不可用"),
    504: ("Gateway Timeout", "网关超时"),
    505: ("HTTP Version Not Supported", "HTTP版本不受支持"),
    506: ("Variant Also Negotiates", "内容协商错误"),
    507: ("Insufficient Storage", "存储空间不足(WebDAV)"),
    508: ("Loop Detected", "检测到循环(WebDAV)"),
    510: ("Not Extended", "需要扩展协议"),
    511: ("Network Authentication Required", "需要网络认证"),
    
    # Cloudflare专有状态码
    520: ("Web Server Returned an Unknown Error", "未知的服务器错误"),
    521: ("Web Server Is Down", "服务器已关闭"),
    522: ("Connection Timed Out", "连接超时"),
    523: ("Origin Is Unreachable", "源站无法访问"),
    524: ("A Timeout Occurred", "握手超时"),
    525: ("SSL Handshake Failed", "SSL握手失败"),
    526: ("Invalid SSL Certificate", "无效的SSL证书"),
    527: ("Railgun Error", "Railgun连接错误"),
    530: ("Origin DNS Error", "源站DNS错误"),
}